package demo.victoryCases;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

public class 用户登录并显示当前日期时间 {
    public static void main(String[] args) {
        Operate operate = new Operate(args);
        System.out.println(operate.login());
    }
}

class Operate {
    private String[] info;
public Operate(String [] info){
    this.info=info;
}
    public String login() {
        String name = info[0];
        String pwd = info[1];
        this.isExist();
        Check check = new Check();
        String calling = null;
        LocalDateTime now = LocalDateTime.now();
        String pattern  ="yyyy年MM月dd日 HH时mm分ss秒";
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern, Locale.CHINA);
        String time = now.format(dateTimeFormatter);
        if (check.validate(name, pwd)) {
            calling = "你好，" + name + " 现在是北京时间" + time;
        } else {
            calling = "你不属于这里,速速离开！";
        }
        return calling;
    }

    public void isExist() {
        if (info.length < 2) {

            System.exit(1);
        }
    }
}

class Check {
    public boolean validate(String name, String pwd) {
        if ("王境泽".equals(name) && "222".equals(pwd)) {
            return true;
        } else {
            return false;
        }
    }
}